package com.ycfmedical.bed.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ycfmedical.bed.R;
import com.ycfmedical.bed.local.entity.BillRecords;

import butterknife.BindView;
import cn.droidlover.xdroidmvp.base.SimpleRecAdapter;
import cn.droidlover.xdroidmvp.kit.KnifeKit;

/**
 * Created by yf on 2017-04-29.
 *
 */

public class BillCheckAdapter extends SimpleRecAdapter<BillRecords, BillCheckAdapter.ViewHolder> {
private int billCheckAdapterType;//

/**@param billCheckAdapterType 1代表费用明细列表；2代表缴费明细列表
 * */
    public BillCheckAdapter(Context context, int billCheckAdapterType) {
        super(context);
        this.billCheckAdapterType = billCheckAdapterType;
    }

    @Override
    public ViewHolder newViewHolder(View itemView) {
        return new ViewHolder(itemView);
    }

    @Override
    public int getLayoutId() {
        return R.layout.adapter_checkbill;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {

        BillRecords billCheck=data.get(position);

        if(position==0){
            holder.ExcelC1.setBackgroundColor(context.getResources().getColor(R.color.hisbg_blue));
            holder.ExcelC2.setBackgroundColor(context.getResources().getColor(R.color.hisbg_blue));
            holder.ExcelC3.setBackgroundColor(context.getResources().getColor(R.color.hisbg_blue));
            holder.ExcelC4.setBackgroundColor(context.getResources().getColor(R.color.hisbg_blue));

            holder.ExcelC1.setTextColor(context.getResources().getColor(R.color.hisbg_TextWhite));
            holder.ExcelC2.setTextColor(context.getResources().getColor(R.color.hisbg_TextWhite));
            holder.ExcelC3.setTextColor(context.getResources().getColor(R.color.hisbg_TextWhite));
            holder.ExcelC4.setTextColor(context.getResources().getColor(R.color.hisbg_TextWhite));
        }else {
            holder.excelLiner.setBackgroundColor(context.getResources().getColor(R.color.white));
            holder.ExcelC1.setTextColor(context.getResources().getColor(R.color.hisbg_Textblue));
            holder.ExcelC2.setTextColor(context.getResources().getColor(R.color.hisbg_TextGray));
            holder.ExcelC3.setTextColor(context.getResources().getColor(R.color.hisbg_TextGray));
            holder.ExcelC4.setTextColor(context.getResources().getColor(R.color.hisbg_TextGray));
        }

        holder.ExcelC1.setText(billCheck.getExcelC1());
        holder.ExcelC2.setText(billCheck.getExcelC2());
        holder.ExcelC3.setText(billCheck.getExcelC3());
        holder.ExcelC4.setText(billCheck.getExcelC4());

    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.excel_liner)
        LinearLayout excelLiner;
        @BindView(R.id.ExcelC1)
        TextView ExcelC1;
        @BindView(R.id.ExcelC2)
        TextView ExcelC2;
        @BindView(R.id.ExcelC3)
        TextView ExcelC3;
        @BindView(R.id.ExcelC4)
        TextView ExcelC4;

        public ViewHolder(View itemView) {
            super(itemView);
            KnifeKit.bind(this, itemView);
        }
    }
}
